
function doMove ( obj, attr, dir, target, endFn ) {

	dir = 0 < target ? dir : -dir;

	clearInterval( obj.timer );
	var Int = parseInt(getStyle( obj, attr ))  //?多次点击，多次获取值，导致位置错误
	var aLi = obj.getElementsByTagName('li')
	var len = aLi.length

	obj.timer = setInterval(function () {
		
		var speed = parseInt(getStyle( obj, attr )) + dir;			// 步长
		
		if ( speed > (Int + target) && dir > 0 ||  speed < (Int + target) && dir < 0  ) {
			speed = Int + target;
		}
		if( speed < (len-3)*target && dir < 0){
			speed = (len-3)*target
		}else if( speed > 0 && dir>0){
			speed = 0
		}
		obj.style[attr] = speed + 'px';

		if ( speed ==  (Int + target) )  {
			clearInterval( obj.timer );
			
			/*
			if ( endFn ) {
				endFn();
			}
			*/
			endFn && endFn();
			
		}
		
	}, 100);
}

function opacity(obj, dir, target, endFn){
	var num = dir
	var timer = null;

	clearInterval(timer)
	timer = setInterval(function(){
		if( dir > target ){
			num -= 0.01;
			if( num < 0){
				num = 0;
			}
			obj.style.opacity = num;
			if( num == 0){
				clearInterval(timer)
				endFn && endFn();
			}
		}
		if( dir < target ){
			num += 0.01;
			if( num > 1){
				num = 1;
			}
			obj.style.opacity = num;
			if( num == 1){
				clearInterval(timer)
				endFn && endFn();
			}
		}
	},20)
}

function getStyle ( obj, attr ) { return obj.currentStyle?obj.currentStyle[attr] : getComputedStyle( obj )[attr]; }